﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 装备，捡起来获得属性强化
/// </summary>
public class Equipment : ItemBase
{
    public int Hpup;
    public int Atkup;
    public int Defup;

    

    /// <summary>
    /// 捡起装备
    /// </summary>
    public override void ItemAction()
    {
        base.ItemAction();
        Debug.LogWarning("这里也执行了");
        if (Hpup > 0)
        {
            EventNodeCore.GetInstance().HandleEvent(EventDef.HpChange, Hpup, PlayerManager.Instance.gameObject);
        }
        if (Defup > 0)
        {
            EventNodeCore.GetInstance().HandleEvent(EventDef.DefChange, Defup, PlayerManager.Instance.gameObject);
        }
        if (Atkup > 0)
        {
            EventNodeCore.GetInstance().HandleEvent(EventDef.AtkChange, Atkup, PlayerManager.Instance.gameObject);
        }
        
    }

    /// <summary>
    /// 设置属性
    /// </summary>
    /// <param name="hp"></param>
    /// <param name="atk"></param>
    /// <param name="def"></param>
    public void SetProperty(int hp, int atk, int def)
    {
        Hpup = hp;
        Atkup = atk;
        Defup = def;
    }

    public override void Initiate()
    {
        base.Initiate();
    }

    public override IEnumerator VanishAct()
    {
        float time = 0;
        while (time < 1)
        {
            time += Time.deltaTime;
            transform.position += transform.up * 0.02f;
            yield return null;
        }
        Destroy(gameObject);
    }
}
